package com.tscnd.core.aspect; 

import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.AfterThrowing;
import org.aspectj.lang.annotation.Aspect;
import org.springframework.stereotype.Component;
import org.springframework.test.annotation.Rollback;
import org.springframework.transaction.interceptor.TransactionAspectSupport;

@Aspect //该注解标示该类为切面类   
@Component
public class RollbackAspect {

	 @AfterThrowing(pointcut="execution(* com.tscnd.core.service..*.*(..)) && @annotation(ro)", throwing="ex")
	public void rollback(JoinPoint point, Rollback ro,Throwable ex) throws Throwable{
		if(ro.value()){
			TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
		}
	}
}
